<html>
<head><meta content="text/html; charset=utf-8" http-equiv="content-type">
<title>RGB网页颜色在线取色器</title>
<script language="javascript">
function $(id){
  obj=document.getElementById(id);
  if (obj==null) obj=document.all.id;
  return obj;
}

//检查颜色值-END
var SelRGB = '#808080';
var DrRGB = "";
var SelGRAY = '120';
var SelCol="";
var baseCol="#808080";
var light="120";
var RGB=$("RGB");
var hexch = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');


function ToHex(n)
{  var h, l;
  n = Math.round(n);
  l = n % 16;
  h = Math.floor((n / 16)) % 16;
  return (hexch[h] + hexch[l]);
}

function ct_led(e){
SelRGB = e.bgColor;
var aa=transferColorToRgb(SelRGB);
alert(aa);
return location.href='s.html?cl='+aa;
}

</script>
</head>
<body bgcolor=#ffffff text=#000000 vlink=#0033CC alink=#800080 link=#0033cc topmargin="0">
<form action="" method="">
<TABLE ID=ColorTable BORDER=0 CELLSPACING=2 CELLPADDING=0 style='cursor:pointer'>
<SCRIPT LANGUAGE=JavaScript>

function transferColorToRgb(color) {
            var reg = /\w{2}/g;
            var colors = color.match(reg);
            for (var i = 0; i < colors.length; i++) {
                colors[i] = parseInt(colors[i], 16).toString();
            }
            return 'rgb(' + colors.join() + ')';
        }

function wc(r, g, b, n)
{
  r = ((r * 16 + r) * 3 * (15 - n) + 0x80 * n) / 15;
  g = ((g * 16 + g) * 3 * (15 - n) + 0x80 * n) / 15;
  b = ((b * 16 + b) * 3 * (15 - n) + 0x80 * n) / 15;
  document.write('<TD BGCOLOR=#' + ToHex(r) + ToHex(g) + ToHex(b) + ' height=8 width=12    onmousedown="ct_led(this)"></TD>');
}


var cnum = new Array(1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0);
 for(i = 0; i < 16; i ++)
 {
   document.write('<TR>');
   for(j = 0; j < 30; j ++)
   {
     n1 = j % 5;
     n2 = Math.floor(j / 5) * 3;
     n3 = n2 + 3;
     wc((cnum[n3] * n1 + cnum[n2] * (5 - n1)),
       (cnum[n3 + 1] * n1 + cnum[n2 + 1] * (5 - n1)),
       (cnum[n3 + 2] * n1 + cnum[n2 + 2] * (5 - n1)), i);
   }
   document.writeln('</TR>');
 }
</SCRIPT>
</TABLE>
</form>
</div>
</body>
</html>

